﻿using FluentValidation;
using SDF.Admin.Models.Projects;
using SDF.Core.Domain.Projects;
using SDF.Data;
using SDF.Services.Localization;
using SDF.Web.Framework.Validators;

namespace SDF.Admin.Validators.Projects
{
    public partial class ProjectValidator : BaseSDFValidator<ProjectModel>
    {
        public ProjectValidator(ILocalizationService localizationService, IDbContext dbContext)
        {
            RuleFor(x => x.Name).NotEmpty().WithMessage(localizationService.GetResource("Admin.Configuration.Projects.Fields.Name.Required"));
            RuleFor(x => x.Url).NotEmpty().WithMessage(localizationService.GetResource("Admin.Configuration.Projects.Fields.Url.Required"));

            SetStringPropertiesMaxLength<Project>(dbContext);
        }
    }
}